﻿
#include <iostream>
using namespace std;

void PrintN(int N)
{
	int i;
	for (i =1; i<=N;i++)
	{
		cout << i << endl;
	}
}

// 最大子列问题
int MaxSubseqSum(int Array[], int N)
{
	int thisSum=0, maxSum =0;
	
	for (int i=0;i<N;i++)
	{
		thisSum += Array[i];

		if (thisSum < 0)
		{
			thisSum = 0;
		}
		else if (thisSum > maxSum)
		{
			maxSum = thisSum;
		}
	}

	return maxSum;
}

int main()
{
	/*int N;
	cin >> N;
	PrintN(N);*/

	int Array[] = { -2 ,11 ,- 4 ,13, - 5 ,- 2 };
	cout << MaxSubseqSum(Array, 6);
	return 0;
}

